library(coda)
library(foreign)
library(inline)
library(Rcpp)
library(gtools)
library(pscl)
library(parallel)
library(rstanmulticore)
library("rstan", lib.loc="~/R/win-library/3.2")
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())


eudata1<-read.table("model1.txt")
stan_eu_data1<-list(N=nrow(eudata1), K=126, E=6, y=eudata1[,1], x=eudata1[,2:127], ep=eudata1[,128])
fit.parallel_1<-pstan(file="model1.stan", model_name="Model 1", data=stan_eu_data1,iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudata2<-read.table("model2.txt")
stan_eu_data2<-list(N=nrow(eudata2), K=126, E=6, y=eudata2[,1], x=eudata2[,2:127], ep=eudata2[,128])
fit.parallel_2<-pstan(file="model2.stan", model_name="Model 2", data=stan_eu_data3, iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudata3<-read.table("model3.txt")
stan_eu_data3<-list(N=nrow(eudata3), K=127, E=6, y=eudata3[,1], x=eudata3[,2:128], ep=eudata3[,129])
fit.parallel_3<-pstan(file="model3.stan", model_name="Model 3", data=stan_eu_data3, iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudat4<-read.table("model4.txt")
stan_eu_data4<-list(N=nrow(eudata4), K=131, E=6, y=eudata4[,1], x=eudata4[,2:132], ep=eudata4[,133])
fit.parallel_4<-pstan(file="model4.stan", model_name="Model 4", data=stan_eu_data4,  iter=15000, 
                    warmup=1000,  chains=4, seed=1, thin=5)

eudata5<-read.table("model5.txt")
stan_eu_data5<-list(N=nrow(eudata5), K=119, E=5, y=eudata5[,1], x=eudata5[,2:120], ep=eudata5[,121])
fit.parallel_5<-pstan(file="model5.stan", model_name="Model 5", data=stan_eu_data5, iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudata6<-read.table("model6.txt")
stan_eu_data6<-list(N=nrow(eudata6), K=126, E=6, y=eudata6[,1], x=eudata6[,2:127], ep=eudata6[,128])
fit.parallel_6<-pstan(file="model6.stan", model_name="Model 6", data=stan_eu_data6, iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudata7<-read.table("model7.txt")
stan_eu_data7<-list(N=nrow(eudata7), K=126, E=6, y=eudata7[,1], x=eudata7[,2:127], ep=eudata7[,128])
fit.parallel_7<-pstan(file="model7.stan", model_name="Model 7", data=stan_eu_data7, iter=15000, 
                    warmup=1000,  chains=4, seed=1, thin=5)

eudata8<-read.table("model8.txt")
stan_eu_data8<-list(N=nrow(eudata8), K=127, E=6, y=eudata8[,1], x=eudata8[,2:128], ep=eudata8[,129])
fit.parallel_8<-pstan(file="model8.stan", model_name="Model 8", data=stan_eu_data8, iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudata9<-read.table("model9.txt")
stan_eu_data9<-list(N=nrow(eudata9), K=131, E=6, y=eudata9[,1], x=eudata9[,2:132], ep=eudata9[,133])
fit.parallel_9<-pstan(file="model9.stan", model_name="Model 9", data=stan_eu_data9, iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)

eudata10<-read.table("model10.txt")
stan_eu_data10<-list(N=nrow(eudata10), K=119, E=5, y=eudata10[,1], x=eudata10[,2:120], ep=eudata10[,121])
fit.parallel_10<-pstan(file="RnR 1 no6.stan", model_name="RnR 13", data=stan_eu_data1,  iter=15000, 
                    warmup=10000,  chains=4, seed=1, thin=5)


